<? 
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php"); 
	
	checkAccess("allow_online_member_view",1); 
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?	
		
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data Inserted</div>";
				break;
			case 2:
				$msg="<div class='dw_success'>Data Deleted</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;
			case 4:
				$msg="<div class='dw_success'>Discount Voucher Sent</div>";
				break;		
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	
	
	
	$id=$_GET['id'];
	$get_id=mysql_query("select * from os_member where id=$id");

	$a=mysql_fetch_array($get_id,MYSQL_ASSOC);
	
	$get_totalpurchase=mysql_query("select count(*)as result from os_bill_details where uid=$id and status=6");
	$get_totalprocess=mysql_query("select count(*)as result from os_bill_details where uid=$id and status<6 and status>0");
	$get_totalother=mysql_query("select count(*)as result from os_bill_details where uid=$id and status<0");
	$get_totalvoucher=mysql_query("select count(*)as result from os_discount_voucher_used where member_id=$id");
	$get_totalusedvoucher=mysql_query("select count(*)as result from os_discount_voucher_used where member_id=$id and status=1");

?>
				<table width="100%"  cellpadding="0" cellspacing="5" height="300">
				
					<td valign="top">
                    	 <div id="divMsg"><?= $msg ?></div>
						<table width="100%">
							<tr>
								<td colspan="5" class="title">Member Information</td>
							</tr>
							<tr>
								<td colspan="3"><strong>Statistic</strong></td>
							</tr>
							<tr valign="top">
								<td width="31%">Total login</td><td width="6%">:</td><td width="63%"><?= $a['total_login'] ?></td>
							</tr>
							<tr valign="top">
								<td width="31%">Total successfull purchase</td><td width="6%">:</td><td width="63%"><?= mysql_result($get_totalpurchase,0,"result") ?> (<a href="member_purchaselist.php?id=<?= $id ?>">View</a>)</td>
							</tr>
							<tr valign="top">
								<td width="31%">Total under proccessing purchase</td><td width="6%">:</td><td width="63%"><?= mysql_result($get_totalprocess,0,"result") ?> (<a href="member_prolist.php?id=<?= $id ?>">View</a>)</td>
							</tr>
							<tr valign="top">
								<td width="31%">Total expired/cancelled</td><td width="6%">:</td><td width="63%"><?= mysql_result($get_totalother,0,"result") ?> (<a href="member_otherlist.php?id=<?= $id ?>">View</a>)</td>
							</tr>
                            <?
								if($module_gift_voucher==1)
								{
							?>
                            <tr valign="top">
								<td width="31%">Total voucher used / Total voucher</td><td width="6%">:</td>
                                <td width="63%">
								<?= mysql_result($get_totalusedvoucher,0,"result") ?>  / <?= mysql_result($get_totalvoucher,0,"result") ?> (<a href="member_dv_list.php?id=<?= $id ?>">View</a> | 
                                <a href="dv_send.php?id=<?= $id ?>">Send Voucher</a>)
                                </td>
							</tr>
                             <tr valign="top">
								<td>Member Points</td><td>:</td><td><?= getMemberPoints($a['id']) ?></td>
							</tr>
                            <? } ?>
							<tr>
								<td colspan="3"><br><br><strong>Account</strong></td>
							</tr>
							<tr valign="top">
								<td>Email</td><td>:</td><td><?= $a['email'] ?></td>
								</tr>
							<tr valign="top">
								<td>Account status</td><td>:</td><td><?= $a['status'] ?></td>
							</tr>
                            <tr valign="top">
								<td>Membership Number</td><td>:</td><td><?= $a['membership_number'] ?></td>
							</tr>
							<tr valign="top">
								<td>Member Type</td><td>:</td><td><?= convertMemberType($a['member_type']) ?></td>
							</tr>
							<tr>
							<td colspan="3"><br><br><strong>Personal Information</strong></td>
							</tr>
							<tr>
								<td>First Name</td><td>:</td><td><?= $a['name'] ?></td>
							</tr>
                            <tr>
								<td>Last Name</td><td>:</td><td><?= $a['last_name'] ?></td>
							</tr>
							<?
								if($a['gender']=="male")
								{
									$sex="Male";
								}
								else
								{
									$sex="Female";
								}
							?>
							<tr>
								<td>Gender</td><td>:</td><td><?= $sex ?></td>
							</tr>
							<tr>
								<td>Birth date</td><td>:</td><td><?= $a['dob'] ?></td>
							</tr>
							<tr>
								<td>IC number</td><td>:</td><td><?= $a['icnumber'] ?></td>
							</tr>
							<tr>
							<td colspan="3"><br><br>	<strong>Contact information</strong></td>
							</tr>
							<?
									if($a['state']!=0)
									{
									
										$get_place=mysql_query("select * from os_state where id=".$a['state'])or die(mysql_error());
										if(mysql_num_rows($get_place)==0)
										{
											$state="-";
										}
										else
										{
											$place=mysql_result($get_place,0,"name_eng");
											$state="$place";
										}
									}
									else
									{
										$state="-";
									}
									
									
							?>
							
							
							<tr>
								<td>Area</td><td>:</td><td><?= $state ?></td>
							</tr>
							<tr>
								<td>Address</td><td>:</td><td><?= $a['address1'] ?></td>
							</tr>
							<tr>
								<td colspan="2"></td><td><?= $a['address2'] ?></td>
							</tr>
							<tr>
								<td>Postcode</td><td>:</td><td><?= $a['postcode'] ?></td>
							</tr>
							<tr>
								<td>City</td><td>:</td><td><?= $a['city'] ?></td>
							</tr>
							<tr>
								<td>Contact number</td><td>:</td><td><?= $a['hpnumber'] ?><br></td>
							</tr>
							<tr>
								<td>Fax</td><td>:</td><td><?= $a['fax'] ?><br></td>
							</tr>
							<form action="member_edit.php" method="post">
							<input type="hidden" value="<?= $id ?>" name="id">
							<tr>
								<td colspan="3"> <input type="button" value="Edit" class="button" onclick="window.open('member_edit.php?id=<?= $id ?>','_self')"></td>
							</tr>
							</form>
						</table>
					</td>
				
				 
				</table>
<? require("required/footer.php"); ?>